<template>
    <div>
        <Spin fix v-if="isSpin">
            <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
            <div>正在生成企业安全总监推荐表，请稍后</div>
        </Spin>
        <Form :label-width="100" ref="formInline" :model="formInline">
            <Row :gutter="16" class="query-form2" >
                <i-col span="8">
                    <FormItem label="单位名称：">
                        <Input v-model="formInline.orgName" placeholder="请填写公司名称"/>
                    </FormItem>
                </i-col>
                <i-col span="8">
                    <FormItem label="总监姓名：">
                        <Input v-model="formInline.userName" placeholder="请填写总监姓名"/>
                    </FormItem>
                </i-col>
                <i-col span="8">
                    <div style="float: right;">
                        <Button class="ivu-btn-query"  icon="md-search"  @click="query">查询</Button>
                        <Button class="ivu-btn-reset" style="margin-left: 10px" @click="cancel">重置</Button>
                    </div>
                </i-col>
            </Row>
        </Form>
        <Row type="flex" justify="start" class="query-form">
            <i-col>
                <Button icon="md-add" class="ivu-btn-add" @click="addInfo">新增</Button>
            </i-col>
        </Row>
        <Table ref='table' style="margin-top: 10px" :loading="loading" border :columns="columns" no-data-text="没有查询到相关数据！"
               :data="infos" width="100%" :height="tableHeight" highlight-row stripe size="small"></Table>
        <Row type="flex" justify="end" >
            <i-col>
                <Page :total="pagedata.total" :current="pagedata.currentPage" :page-size="pagedata.pageSize"
                      @on-page-size-change="pageSizeChange" @on-change="pageChange" :page-size-opts="pageSizeArray" show-total show-sizer show-elevator />
            </i-col>
        </Row>
        <Modal v-model="modal1" width="800" :mask-closable="false" :title="'企业安全总监变更' + titleName">
            <div :style="{height: divHeight, overflowY: 'auto', overflowX: 'hidden'}">
                <Form ref="formCustom" :model="formData" :rules="ruleCustom" label-position="top">
                    <Row :gutter="16">
                        <i-col span="18">
                            <Row :gutter="16">
                                <i-col span="24">
                                    <FormItem label="单位名称：" prop="orgName">
                                        <Input type="text" v-model="formData.orgName" readonly/>
                                    </FormItem>
                                </i-col>
                            </Row>
                            <Row :gutter="16">
                                <i-col span="12">
                                    <FormItem label="原总监姓名：">
                                        <Input type="text" v-model="formData.oldUserName" readonly/>
                                    </FormItem>
                                </i-col>
                                <i-col span="12">
                                    <FormItem label="现总监姓名：" prop="userName">
                                        <userDom ref="userDom" :ifUser=true  :singleChoice=true @setData = "setUserInfo" :selectData='{name: formData.userName}' :rootOrgName="rootOrgId"></userDom>
                                    </FormItem>
                                </i-col>
                            </Row>
                            <Row :gutter="16">
                                <i-col span="12">
                                    <FormItem label="性别：" prop="gender">
                                        <Select v-model="formData.gender">
                                            <Option v-for="(item, index) in genderList" :value="item.id" :key="index">{{item.label}}</Option>
                                        </Select>
                                    </FormItem>
                                </i-col>
                                <i-col span="12">
                                    <FormItem label="政治面貌：" prop="politicalAffiliation">
                                        <Select v-model="formData.politicalAffiliation">
                                            <Option v-for="(item, index) in politicalAffiliationList" :value="item.codingCodeId" :key="index">{{item.codingName}}</Option>
                                        </Select>
                                    </FormItem>
                                </i-col>
                            </Row>
                            <Row :gutter="16">
                                <i-col span="12">
                                    <FormItem label="出生年月：" prop="birthday">
                                        <DatePicker v-model="formData.birthday" type="date" placeholder="请选择出生年月" style="width: 100%"></DatePicker>
                                    </FormItem>
                                </i-col>
                                <i-col span="12">
                                    <FormItem label="手机号码：" prop="phoneNumber">
                                        <Input type="text" v-model="formData.phoneNumber"/>
                                    </FormItem>
                                </i-col>
                            </Row>
                        </i-col>
                        <i-col span="6">
                            <FormItem label="一寸免冠照：" prop="photo">
                                <Upload style="display: inline-block;width:58px;" v-show="fileList.length == 0"
                                        multiple
                                        ref="photoUpload"
                                        type="drag"
                                        name="files"
                                        :show-upload-list="false"
                                        :format="['jpg','jpeg','png']"
                                        :before-upload="beforeUpload"
                                        :action="fileUrl">
                                    <div style="width: 58px;height:58px;line-height: 58px;">
                                        <Icon type="ios-camera" size="20"></Icon>
                                    </div>
                                </Upload>
                                <div class="demo-upload-list"  v-for="(item, index) in fileList" :key="index">
                                    <img :src="item.picture" style="width:168px; height:210px"/>
                                    <div class="demo-upload-list-cover">
                                        <Icon type="ios-eye-outline" @click.native="viewFile(item.picture)"></Icon>
                                        <Icon type="ios-trash-outline" @click.native="removeFile(item)"></Icon>
                                    </div>
                                </div>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row :gutter="16">
                        <i-col span="12">
                            <FormItem label="学历：" prop="education">
                                <Select v-model="formData.education">
                                    <Option v-for="(item, index) in educationList" :value="item.codingCodeId" :key="index">{{item.codingName}}</Option>
                                </Select>
                            </FormItem>
                        </i-col>
                        <i-col span="12">
                            <FormItem label="专业：" prop="major">
                                <Input type="text" v-model="formData.major" placeholder="请输入专业" />
                            </FormItem>
                        </i-col>
                    </Row>

                    <Row :gutter="16">
                        <i-col span="12">
                            <FormItem label="现职务（岗位）：" prop="currentPosition">
                                <Input type="text" v-model="formData.currentPosition" placeholder="请输入现职务（岗位）" />
                            </FormItem>
                        </i-col>
                        <i-col span="12">
                            <FormItem label="工作年限：" prop="workYear">
                                <Input type="number" v-model="formData.workYear" placeholder="请输入工作年限"/>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row :gutter="16">
                        <i-col span="12">
                            <FormItem label="现职务（岗位）工作年限：" prop="currentPositionWorkYear">
                                <Input type="number" v-model="formData.currentPositionWorkYear" placeholder="现职务（岗位）工作年限"/>
                            </FormItem>
                        </i-col>
                        <i-col span="12">
                            <FormItem label="与安全生产管理相关的工作年限：" prop="relevantWorkYear" >
                                <Input type="number" v-model="formData.relevantWorkYear" placeholder="请输入与安全生产管理相关的工作年限"/>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row :gutter="16">
                        <i-col span="24">
                            <FormItem label="任职资格：" prop="qualification">
                                <CheckboxGroup v-model="formData.qualificationCheck" @on-change="changeQualification"><Checkbox v-for="item in qualificationList" :label="item.text"></Checkbox></CheckboxGroup>
                                <Input type="text" v-model="formData.qualification" placeholder="请输入任职资格,如果没有相关任职资格，可以输入无，如果有任职资格的话，请上传附件"/>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row :gutter="16">
                        <i-col span="24">
                            <FormItem label="任职资格附件上传：">
                                <Upload
                                        multiple
                                        ref="qualificationUpload"
                                        type="drag"
                                        name="files"
                                        :show-upload-list="false"
                                        :before-upload="beforeUpload2"
                                        :action="fileUrl2">
                                    <div style="padding: 20px 0">
                                        <Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
                                        <p>请上传任职资格附件</p>
                                    </div>
                                </Upload>
                                <div v-show="fileList2.length>0" v-for="item in fileList2" :key='item' style="margin: 3px">
                                    <a @click="downloadFile(item)">{{ item.fileName }} {{ item.name }}</a>
                                    <Button type="text" icon="md-trash" @click="remove2(item)"
                                            style="margin-left: 5px;margin-bottom: 3px"/>
                                </div>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row :gutter="16">
                        <i-col span="24">
                            <FormItem label="工作经历：" prop="workExperience">
                                <Input v-model="formData.workExperience" type="textarea" :rows="4" placeholder="（与安全生产管理相关的工作经历及成果、成绩或突出贡献，可附页）" />
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row :gutter="16">
                        <i-col span="24">
                            <FormItem label="工作经历附件上传：">
                                <Upload
                                        multiple
                                        ref="workExperienceUpload"
                                        type="drag"
                                        name="files"
                                        :show-upload-list="false"
                                        :before-upload="beforeUpload3"
                                        :action="fileUrl3">
                                    <div style="padding: 20px 0">
                                        <Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
                                        <p>请上传工作经历附件</p>
                                    </div>
                                </Upload>
                                <div v-show="fileList3.length>0" v-for="item in fileList3" :key='item' style="margin: 3px">
                                    <a @click="downloadFile(item)">{{ item.fileName }} {{ item.name }}</a>
                                    <Button type="text" icon="md-trash" @click="remove3(item)"
                                            style="margin-left: 5px;margin-bottom: 3px"/>
                                </div>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row :gutter="16">
                        <i-col span="24">
                            <FormItem label="变更原因：" prop="changeReason">
                                <Input v-model="formData.changeReason" type="textarea" :rows="4" placeholder="请输入变更原因" />
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row :gutter="16">
                        <i-col span="24">
                            <FormItem label="变更决定附件：">
                                <Upload
                                        multiple
                                        ref="changeUpload"
                                        type="drag"
                                        name="files"
                                        :show-upload-list="false"
                                        :before-upload="beforeUpload4"
                                        :action="fileUrl4">
                                    <div style="padding: 20px 0">
                                        <Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
                                        <p>请上传工作经历附件</p>
                                    </div>
                                </Upload>
                                <div v-show="fileList4.length>0" v-for="item in fileList4" :key='item' style="margin: 3px">
                                    <a @click="downloadFile(item)">{{ item.fileName }} {{ item.name }}</a>
                                    <Button type="text" icon="md-trash" @click="remove4(item)"
                                            style="margin-left: 5px;margin-bottom: 3px"/>
                                </div>
                            </FormItem>
                        </i-col>
                    </Row>

                </Form>
            </div>
            <div slot="footer">
                <Button @click="saveInfo" class="ivu-btn-save" :loading="buttonLoading">确定</Button>
                <Button @click="modal1 = false" class="ivu-btn-cancel" >取消</Button>
            </div>
        </Modal>
        <Modal v-model="modal2" width="800" :mask-closable="false" title="企业安全总监变更上报">
            <Spin fix v-if="spinShow">
                <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
                <div>表单信息加载中，请稍后</div>
            </Spin>
            <Form ref="reportForm" :model="reportData" :rules="ruleCustom2" label-position="top">
                <Row :gutter="16">
                    <i-col span="24">
                        <FormItem label="企业领导：" prop="leaderId">
                            <Select v-model="reportData.leaderId" style="width: 90%">
                                <Option v-for="(item, index) in leaderList" :value="item.userId" :key="index">{{item.userName}}
                                    <span style="float:right;color:#ccc">{{item.orgName}} （{{item.positionName }}）</span>
                                </Option>
                            </Select>
                            <Button icon="md-person-add" style="margin-left: 5px" @click="selectUser"></Button>
                        </FormItem>
                    </i-col>
                </Row>
            </Form>
            <div slot="footer">
                <Button @click="reportInfo" class="ivu-btn-save" :loading="buttonLoading">上报</Button>
                <Button @click="modal2 = false" class="ivu-btn-cancel" >取消</Button>
            </div>
        </Modal>
        <Modal v-model="modal3" width="900" :mask-closable="false">
            <Tabs>
                <TabPane label="历史记录">
                    <Table ref='table3' :loading="loading3" border :columns="historyColumns" style="margin-top: 0px"
                           :data="infos3" width="100%" :height="500" highlight-row stripe size="small"></Table>
                </TabPane>
                <TabPane label="流程图">
                    <div style="height: 500px; overflow-y: auto; overflow-x: auto">
                        <img :src="imgUrl" >
                    </div>
                </TabPane>
            </Tabs>
            <div slot="footer" >
                <Button @click="modal3=false" class="ivu-btn-save">关闭</Button>
            </div>
        </Modal>
        <Modal v-model="modal4" width="800" :mask-closable="false" title="企业安全总监变更详情">
            <Row class="modal-view-detail">
                <i-col span="24">
                    <Form :model="formData" :label-width="120">
                        <Row  :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col  span="24">
                                <FormItem label="单位名称：">
                                    {{formData.orgName}}
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="12" >
                                <FormItem label="原总监姓名：">
                                    {{formData.oldUserName}}
                                </FormItem>
                            </i-col>
                            <i-col span="12" >
                                <FormItem label="现总监姓名：">
                                    {{formData.userName}}
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="12" >
                                <FormItem label="性别：">
                                    {{formData.gender}}
                                </FormItem>
                            </i-col>
                            <i-col span="12" >
                                <FormItem label="政治面貌：">
                                    {{formData.politicalAffiliationName}}
                                </FormItem>
                            </i-col>
                        </Row>

                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="12" >
                                <FormItem label="出生年月：">
                                    {{this.formatDate(new Date(this.formData.birthday), 'yyyy-MM-dd')}}
                                </FormItem>
                            </i-col>
                            <i-col span="12" >
                                <FormItem label="手机号码：">
                                    {{formData.phoneNumber}}
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="12" >
                                <FormItem label="学历：">
                                    {{formData.educationName}}
                                </FormItem>
                            </i-col>
                            <i-col span="12" >
                                <FormItem label="专业：">
                                    {{formData.major}}
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="12" >
                                <FormItem label="现职务（岗位）：">
                                    {{formData.currentPosition}}
                                </FormItem>
                            </i-col>
                            <i-col span="12" >
                                <FormItem label="工作年限：">
                                    {{formData.workYear}}
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="12" >
                                <FormItem label="现职务（岗位）工作年限：">
                                    {{formData.currentPositionWorkYear}}
                                </FormItem>
                            </i-col>
                            <i-col span="12" >
                                <FormItem label="与安全生产管理相关的工作年限：">
                                    {{formData.relevantWorkYear}}
                                </FormItem>
                            </i-col>
                        </Row>

                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="24" >
                                <FormItem label="任职资格：">
                                    {{formData.qualification}}
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="24" >
                                <FormItem label="任职资格附件：">
                                    <div v-show="fileList2.length>0" v-for="item in fileList2" :key='item'>
                                        <a @click="downloadFile(item)">{{ item.fileName }}</a>
                                    </div>
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="24" >
                                <FormItem label="工作经历：">
                                    {{formData.workExperience}}
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="24" >
                                <FormItem label="工作经历附件：">
                                    <div v-show="fileList3.length>0" v-for="item in fileList3" :key='item'>
                                        <a @click="downloadFile(item)">{{ item.fileName }}</a>
                                    </div>
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="24" >
                                <FormItem label="一寸免冠照：">
                                    <div class="demo-upload-list" v-for="(item, index) in fileList" :key="index">
                                        <template>
                                            <img :src="item.picture">
                                            <div class="demo-upload-list-cover">
                                                <Icon type="ios-eye-outline" @click.native="viewFile(item.picture)"></Icon>
                                                <Icon type="ios-trash-outline" @click.native="removeFile(item)"></Icon>
                                            </div>
                                        </template>
                                    </div>
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="24" >
                                <FormItem label="企业安全总监推荐表：">
                                    <div v-show="sealFile.length>0" v-for="item in sealFile" :key='item'>
                                        <a @click="downloadFile(item)">{{ item.fileName }}</a>
                                    </div>
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="24" >
                                <FormItem label="初审意见：">
                                    {{formData.groupOpinion}}
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="12" >
                                <FormItem label="填报人：">
                                    {{formData.createUserName}}
                                </FormItem>
                            </i-col>
                            <i-col span="12" >
                                <FormItem label="填报人电话：">
                                    {{formData.createUserPhone}}
                                </FormItem>
                            </i-col>
                        </Row>
                    </Form>
                </i-col>
            </Row>
            <div slot="footer">
                <Button @click="modal4 = false" class="ivu-btn-cancel" >取消</Button>
            </div>
        </Modal>

        <Modal v-model="modal5" width="800" :mask-closable="false" title="企业安全总监推荐信息" footer-hide>
            <Form :label-width="100" :model="formInline2">
                <Row :gutter="16" class="query-form2" >
                    <i-col span="8">
                        <FormItem label="单位名称：">
                            <Input v-model="formInline2.orgName" placeholder="请填写公司名称"/>
                        </FormItem>
                    </i-col>
                    <i-col span="8">
                        <FormItem label="姓名：">
                            <Input v-model="formInline2.userName" placeholder="请填写总监姓名"/>
                        </FormItem>
                    </i-col>
                    <i-col span="8">
                        <div style="float: right;">
                            <Button class="ivu-btn-query"  icon="md-search"  @click="queryInfo">查询</Button>
                            <Button class="ivu-btn-reset" style="margin-left: 10px" @click="cancelInfo">重置</Button>
                        </div>
                    </i-col>
                </Row>
            </Form>
            <Table ref='table2' style="margin-top: 10px" :loading="loading2" border :columns="infoColumns" no-data-text="没有查询到相关数据！"
                   :data="infos2" width="100%" height="400" highlight-row stripe size="small"></Table>
            <Row type="flex" justify="end" >
                <i-col>
                    <Page :total="pagedata.total2" :current="pagedata.currentPage2" :page-size="pagedata.pageSize2"
                          @on-page-size-change="pageSizeChange2" @on-change="pageChange2" :page-size-opts="pageSizeArray" show-total show-sizer show-elevator />
                </i-col>
            </Row>
        </Modal>

        <Modal title="附件查看" v-model="visible">
            <img :src="fileImgSrc" style="width: 100%">
            <div slot="footer" >
                <Button @click="visible=false" class="ivu-btn-save">关闭</Button>
            </div>
        </Modal>

        <Modal title="用户列表" v-model="modal6" width="800" footer-hide :mask-closable="false">
            <Form :label-width="100" ref="formInline2" :model="formInline2">
                <Row :gutter="16" class="query-form2">
                    <i-col span="8">
                        <FormItem label="公司名称：">
                            <Input class="query-form-el" v-model="formInline2.orgName"></Input>
                        </FormItem>
                    </i-col>
                    <i-col span="8">
                        <FormItem label="用户名称：">
                            <Input class="query-form-el" v-model="formInline2.userName"></Input>
                        </FormItem>
                    </i-col>
                    <i-col span="8">
                        <div style="float: right;">
                            <Button class="ivu-btn-query" icon="md-search"  @click="queryUser">查询</Button>
                            <Button class="ivu-btn-reset" style="margin-left: 10px" @click="reset">重置</Button>
                        </div>
                    </i-col>
                </Row>
            </Form>
            <Table ref='table2' height="400" :loading="loading4" no-data-text="请选择查询条件!" border :height=400
                   :columns="column"  width="100%" :data="infos2" size="small"></Table>
            <Row type="flex" justify="end" >
                <i-col>
                    <Page :total="pagedata2.total" :current="pagedata2.currentPage" :page-size="pagedata2.pageSize"
                          @on-page-size-change="pageSizeChange" @on-change="pageChange" :page-size-opts="pageSizeArray" show-total show-sizer show-elevator />
                </i-col>
            </Row>
        </Modal>


    </div>
</template>

<script>

    import {Api} from '../../../api'
    import {sessionStorage} from '@/common/cacheUtils.js';
    import orgDom from "@/components/input-org.vue";
    import userDom from "@/components/input-user.vue";

    export default {
        name: "securityDirectorChange",
        components:{
            orgDom,
            userDom
        },
        data(){
            return{
                IfRepeat: true,
                rootOrgId: '18000000',
                isSpin: false,
                spinShow: false,
                imgUrl: '',
                divHeight: '',
                buttonLoading: false,
                loading: false,
                loading2: false,
                loading3: false,
                loading4: false,
                formInline: {},
                formInline2: {},
                tableHeight: '',
                titleName: '',
                isUpdate: false,
                pagedata: {
                    total: 0,
                    pageSize: 10,
                    currentPage: 1,
                    total2: 0,
                    pageSize2: 10,
                    currentPage2: 1,
                },
                pagedata2: {
                    total: 0,
                    pageSize: 10,
                    currentPage: 1,
                },
                pageSizeArray: [10, 20, 50],
                columns:[
                    {
                        type: 'index',
                        title: '序号',
                        width: 80,
                        align: 'center',
                        fixed: 'left',
                    },
                    {
                        title: '状态',
                        align: 'center',
                        key: 'status',
                        minWidth: 80,
                        render:(h,params)=>{
                            let color = 'green';
                            if(params.row.status == undefined || params.row.status == null ||params.row.status == 2){
                                color = 'red';
                            }
                            return h('div', [
                                h('span', {
                                    style: {
                                        color: color
                                    }
                                },params.row.status == 1 ? '审批中': params.row.status == 2 ? '被退回': params.row.status == 3 ? '已完成': params.row.status == 5? '已终止' : '未上报' || '--')
                            ]);
                        }
                    },
                    {
                        title: '单位名称',
                        align: 'center',
                        key: 'orgName',
                        minWidth: 200,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.orgName || '--')
                            ]);
                        }
                    },
                    {
                        title: '原总监姓名',
                        align: 'center',
                        key: 'userName',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.oldUserName || '--')
                            ]);
                        }
                    },
                    {
                        title: '现总监姓名',
                        align: 'center',
                        key: 'userName',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.userName || '--')
                            ]);
                        }
                    },
                    {
                        title: '性别',
                        align: 'center',
                        key: 'gender',
                        minWidth: 80,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.gender || '--')
                            ]);
                        }
                    },
                    {
                        title: '政治面貌',
                        align: 'center',
                        key: 'politicalAffiliationName',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.politicalAffiliationName || '--')
                            ]);
                        }
                    },
                    {
                        title: '出生年月',
                        align: 'center',
                        key: 'birthday',
                        minWidth: 140,
                        render:(h,params)=>{
                            return h('div',[
                                h('span', params.row.birthday!= null ?this.formatDate(new Date(params.row.birthday), 'yyyy-MM-dd'): '--')
                            ]);
                        }
                    },
                    {
                        title: '手机号码',
                        align: 'center',
                        key: 'phoneNumber',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.phoneNumber || '--')
                            ]);
                        }
                    },
                    {
                        title: '学历',
                        align: 'center',
                        key: 'educationName',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.educationName || '--')
                            ]);
                        }
                    },
                    {
                        title: '专业',
                        align: 'center',
                        key: 'major',
                        minWidth: 150,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.major || '--')
                            ]);
                        }
                    },
                    {
                        title: '现职务（岗位）',
                        align: 'center',
                        key: 'currentPosition',
                        minWidth: 150,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.currentPosition || '--')
                            ]);
                        }
                    },
                    {
                        title: '工作年限',
                        align: 'center',
                        key: 'workYear',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.workYear || '--')
                            ]);
                        }
                    },
                    {
                        title: '安全工作年限',
                        align: 'center',
                        key: 'relevantWorkYear',
                        minWidth: 150,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.relevantWorkYear || '--')
                            ]);
                        }
                    },
                    {
                        title: '任职资格',
                        align: 'center',
                        key: 'qualification',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.qualification || '--')
                            ]);
                        }
                    },
                    {
                        title: '操作',
                        align: 'center',
                        key: 'view',
                        fixed: 'right',
                        minWidth: 350,
                        render: (h, params) => {
                            return h('div', [
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px'
                                    },
                                    on: {
                                        click: () => {
                                            this.updateRow(params.row, "1");
                                            this.$http.get(Api.uploadPTWFiles   + '/' + params.row.id + '/files/picture', {
                                                params: {field: 'seal'},
                                            }).then((res) => {
                                                if(res.data.data!=undefined){ this.sealFile = res.data.data; }
                                            })
                                            this.modal4 = true;

                                        }
                                    }
                                }, '详情'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: params.row.status == "1" || params.row.status == "2" || params.row.status == "3"? '#d0d0d0' : '',
                                        pointerEvents: params.row.status == "1" || params.row.status == "2" || params.row.status == "3"? 'none' : ''
                                    },
                                    on: {
                                        click: () => {
                                            this.titleName = "修改";
                                            this.isUpdate = true;
                                            this.updateRow(params.row);
                                            this.modal1 = true;
                                        }
                                    }
                                }, '修改'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: params.row.status == "1" || params.row.status == "2" || params.row.status == "3"? '#d0d0d0' : '',
                                        pointerEvents: params.row.status == "1" || params.row.status == "2" || params.row.status == "3"? 'none' : ''
                                    },
                                    on: {
                                        click: () => {
                                            this.$set(this.reportData, 'workId', params.row.id);
                                            this.formData = JSON.parse(JSON.stringify(params.row));
                                            this.queryLeader();
                                            this.modal2 = true;
                                        }
                                    }
                                }, '上报'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: params.row.status == "1" || params.row.status == "2" || params.row.status == "3"|| params.row.status == "5"? '' : '#d0d0d0',
                                        pointerEvents: params.row.status == "1" || params.row.status == "2" || params.row.status == "3"|| params.row.status == "5" ? '' : 'none'
                                    },
                                    on: {
                                        click: () => {
                                            this.imgUrl = Api.getFlowImg + '/' + params.row.procinstId
                                            this.queryHistory(params.row);
                                            this.modal3 = true;
                                        }
                                    }
                                }, '流程图'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: params.row.status == "1" || params.row.status == "2" || params.row.status == "3"? '#d0d0d0' : 'red',
                                        pointerEvents: params.row.status == "1" || params.row.status == "2" || params.row.status == "3" ? 'none' : ''
                                    },
                                    on: {
                                        click: () => {
                                            this.deleteRow(params.row);
                                        }
                                    }
                                }, '删除'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                    },
                                    on: {
                                        click: () => {
                                            this.export(params.row)
                                        }
                                    }
                                }, '下载推荐表')
                            ]);
                        }
                    }
                ],
                infos: [],
                formData: {},
                ruleCustom: {
                    orgName: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    userName: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    gender: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    politicalAffiliation: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    birthday: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change',
                            type: 'date'
                        }
                    ],
                    education: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    major: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    currentPosition: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    workYear: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change',
                            // validator: (rule, value, callback) => {
                            //     if (this.formData.workYear % 1 != 0) {
                            //         callback(' ');
                            //     } else {
                            //         callback()
                            //     }
                            // },
                        }
                    ],
                    relevantWorkYear: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change',
                            // validator: (rule, value, callback) => {
                            //     if (this.formData.relevantWorkYear % 1 != 0) {
                            //         callback(' ');
                            //     } else {
                            //         callback()
                            //     }
                            // },
                        }
                    ],
                    currentPositionWorkYear: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change',
                            // validator: (rule, value, callback) => {
                            //     if (this.formData.currentPositionWorkYear % 1 != 0) {
                            //         callback(' ');
                            //     } else {
                            //         callback()
                            //     }
                            // },
                        }
                    ],
                    qualification: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    workExperience: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    phoneNumber: [
                        {
                            validator: (rule, value, callback) => {
                                if (!(/^1[3456789]\d{9}$/.test(this.formData.phoneNumber))) {
                                    callback(' ');
                                } else {
                                    callback()
                                }
                            },
                            required: true,
                            trigger: 'blur'
                        }
                    ],
                    appointmentStartDate: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change',
                            type: 'date'
                        }
                    ],
                    appointmentEndDate: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change',
                            type: 'date'
                        }
                    ],
                    changeReason: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ]
                },
                modal1: false,
                modal2: false,
                modal3: false,
                modal4: false,
                modal5: false,
                modal6: false,
                userInfo: sessionStorage('userId').getObject('userId'),
                fileUrl: '',
                fileUrl2: '',
                fileUrl3: '',
                fileUrl4: '',
                genderList: [
                    {
                        id: '男',
                        label: '男'
                    },
                    {
                        id: '女',
                        label: '女'
                    }
                ],
                qualificationsList:[
                    {
                        id: '符合',
                        label: '符合'
                    },
                    {
                        id: '视同符合',
                        label: '视同符合'
                    }
                ],
                politicalAffiliationList: [],
                educationList: [],
                historyColumns: [
                    {
                        type: 'index',
                        title: '序号',
                        width: 80,
                        align: 'center',
                    },
                    {
                        width: 180,
                        title: '审批时间',
                        key: 'endTime',
                        align: 'center',
                    },
                    {
                        width: 185,
                        title: '节点名称',
                        key: 'name',
                        align: 'center',
                    },
                    {
                        width: 120,
                        title: '审批人',
                        key: 'userName',
                        align: 'center'
                    },
                    {
                        width: 100,
                        title: '审批意见',
                        key: 'route',
                        align: 'center'
                    },
                    {
                        width: 200,
                        title: '备注',
                        key: 'opinions',
                        align: 'center'
                    },
                ],
                infos3: [],
                leaderList: [],
                reportData: {},
                ruleCustom2: {
                    leaderId: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ]
                },
                fileList: [],
                fileList2: [],
                fileList3: [],
                fileList4: [],
                sealFile: [],
                fileImgSrc: '',
                visible: false,
                infoColumns: [
                    {
                        type: 'index',
                        title: '序号',
                        width: 80,
                        align: 'center',
                        fixed: 'left',
                    },
                    {
                        title: '单位名称',
                        align: 'center',
                        key: 'orgName',
                        fixed: 'left',
                        minWidth: 200,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.orgName || '--')
                            ]);
                        }
                    },

                    {
                        title: '姓名',
                        align: 'center',
                        key: 'userName',
                        fixed: 'left',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.userName || '--')
                            ]);
                        }
                    },
                    {
                        title: '性别',
                        align: 'center',
                        key: 'gender',
                        minWidth: 80,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.gender || '--')
                            ]);
                        }
                    },
                    {
                        title: '政治面貌',
                        align: 'center',
                        key: 'politicalAffiliationName',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.politicalAffiliationName || '--')
                            ]);
                        }
                    },
                    {
                        title: '出生年月',
                        align: 'center',
                        key: 'birthday',
                        minWidth: 140,
                        render:(h,params)=>{
                            return h('div',[
                                h('span', params.row.birthday!= null ?this.formatDate(new Date(params.row.birthday), 'yyyy-MM-dd'): '--')
                            ]);
                        }
                    },
                    {
                        title: '手机号码',
                        align: 'center',
                        key: 'phoneNumber',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.phoneNumber || '--')
                            ]);
                        }
                    },
                    {
                        title: '学历',
                        align: 'center',
                        key: 'educationName',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.educationName || '--')
                            ]);
                        }
                    },
                    {
                        title: '专业',
                        align: 'center',
                        key: 'major',
                        minWidth: 150,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.major || '--')
                            ]);
                        }
                    },
                    {
                        title: '现职务（岗位）',
                        align: 'center',
                        key: 'currentPosition',
                        minWidth: 150,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.currentPosition || '--')
                            ]);
                        }
                    },
                    {
                        title: '工作年限',
                        align: 'center',
                        key: 'workYear',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.workYear || '--')
                            ]);
                        }
                    },
                    {
                        title: '现岗位工作年限',
                        align: 'center',
                        key: 'currentPositionWorkYear',
                        minWidth: 150,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.currentPositionWorkYear || '--')
                            ]);
                        }
                    },
                    {
                        title: '安全工作年限',
                        align: 'center',
                        key: 'relevantWorkYear',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.relevantWorkYear || '--')
                            ]);
                        }
                    },
                    {
                        minWidth: 180,
                        title: '任职资格',
                        align: 'center',
                        key: 'groupOpinion',
                        tooltip: true,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.groupOpinion || '--')
                            ]);
                        }
                    },
                    {
                        title: '操作',
                        align: 'center',
                        key: 'view',
                        fixed: 'right',
                        minWidth: 80,
                        render: (h, params) => {
                            return h('div', [
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px'},
                                    on: {
                                        click: () => {
                                            this.modal5 = false;
                                            this.modal1 = true;

                                            this.formData.infoId = params.row.id;
                                            this.formData.oldUserName = params.row.userName;
                                            this.formData.orgId = params.row.orgId;
                                            this.formData.orgName = params.row.orgName;
                                            this.rootOrgId = params.row.orgName;
                                            this.getSecurityDirectorInfoByName();
                                        }
                                    }
                                }, '选择')
                            ]);
                        }
                    }
                ],
                infos2: [],
                formInline2: {},
                qualificationList: [
                    {
                        text: '机电工程师'
                    },
                    {
                        text: '土建工程师'
                    },
                    {
                        text: '安全工程师'
                    },
                ],
                column: [
                    {
                        type: 'index',
                        title: '序号',
                        width: 80,
                        align: 'center',
                    },
                    {
                        minWidth: 100,
                        title: '用户名称',
                        key: 'userName',
                        align: 'center',
                    },
                    {
                        minWidth: 140,
                        title: '岗位名称',
                        key: 'positionName',
                        align: 'center',
                    },
                    {
                        minWidth: 180,
                        title: '二级集团',
                        key: 'twoLevelOrgName',
                        align: 'center',
                    },
                    {
                        minWidth: 180,
                        title: '所属公司',
                        key: 'companyName',
                        align: 'center',
                    },
                    {
                        minWidth: 180,
                        title: '所属部门',
                        key: 'orgName',
                        align: 'center',
                    },
                    {
                        title: '操作',
                        align: 'center',
                        key: 'view',
                        fixed: 'right',
                        minWidth: 80,
                        render: (h, params) => {
                            return h('div', [
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px'
                                    },
                                    on: {
                                        click: () => {
                                            this.$set(this.reportData, 'leaderId', params.row.userId);
                                            this.leaderList.push({userId: params.row.userId, userName: params.row.userName});
                                            this.modal6 = false;
                                        }
                                    }
                                }, '选择')
                            ])
                        }
                    }
                ],
                infos2: [],

            }
        },
        mounted(){
            this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
            this.divHeight = window.innerHeight - 150 +'px';
            this.selectCodingSort();
            this.query();
        },
        watch: {
            "modal1":function(qw,er){
                if(!qw){
                    this.formData = {};
                    this.fileList = [];
                    this.fileList2 = [];
                    this.fileList3 = [];
                    this.fileList4 = [];
                    this.IfRepeat = true;
                }
            },
            "modal4":function(qw,er){
                if(!qw){
                    this.formData = {};
                    this.fileList = [];
                    this.fileList2 = [];
                    this.fileList3 = [];
                    this.fileList4 = [];
                }
            },
            "visible":function(qw,er){
                if(!qw){
                    this.fileImgSrc = '';
                }
            }
        },
        methods:{
            selectCodingSort(){
                this.$http.get(Api.queryCodeDetailBySortId + '/1000001031', {params: {}}).then((res) => {
                    this.politicalAffiliationList = res.data.data;
                });
                this.$http.get(Api.queryCodeDetailBySortId + '/1000001032', {params: {}}).then((res) => {
                    this.educationList = res.data.data;
                });
            },
            query(){
                this.loading = true;
                let data = {
                    startPage: this.pagedata.currentPage,
                    pageSize: this.pagedata.pageSize,
                    orgId: this.userInfo.companyId
                };
                data = Object.assign(data,JSON.parse(JSON.stringify(this.formInline)));
                this.$http.get(Api.securityDirectorInfo + '/change', {
                    params: data
                }).then(function(res){
                    this.infos = res.data.data.data;
                    this.pagedata.total = res.data.data.totalSize;
                    this.loading = false;
                }, function(res){
                    this.$Message.error('请求失败');
                });
            },
            pageSizeChange(pageSize){
                this.pagedata.pageSize = pageSize;
                this.query();
            },
            pageChange(pageNum){
                this.pagedata.currentPage = pageNum;
                this.query();
            },
            cancel(){
                this.formInline = {};
                this.query();
            },
            addInfo(){
                this.modal5 = true;
                this.isUpdate = false;
                this.titleName = '新增';
                this.formData = {
                    id: this.uuid(),
                    createUserId: this.userInfo.userId,
                    createUserName: this.userInfo.userName,
                    createUserPhone: this.userInfo.mobileNumber
                };
                this.queryInfo();
                this.fileUrl = Api.uploadPTWFiles  + '/' + this.formData.id + '/files/picture/photo';
                this.fileUrl2 = Api.uploadPTWFiles  + '/' + this.formData.id + '/files/guideFile/qualification';
                this.fileUrl3 = Api.uploadPTWFiles  + '/' + this.formData.id + '/files/guideFile/workExperience';
                this.fileUrl4 = Api.uploadPTWFiles  + '/' + this.formData.id + '/files/guideFile/change';
                setTimeout(() => {
                    this.$refs.userDom.setCurrentInfo();
                }, 300);
            },
            updateRow(row){
                this.formData = JSON.parse(JSON.stringify(row));
                if(this.formData.qualification != undefined && this.formData.qualification != null)
                    this.formData.qualificationCheck = this.formData.qualification.split("、");

                this.rootOrgId = this.formData.orgName;
                this.fileUrl = Api.uploadPTWFiles  + '/' + this.formData.id + '/files/picture/photo';
                this.fileUrl2 = Api.uploadPTWFiles  + '/' + this.formData.id + '/files/guideFile/qualification';
                this.fileUrl3 = Api.uploadPTWFiles  + '/' + this.formData.id + '/files/guideFile/workExperience';
                this.fileUrl4 = Api.uploadPTWFiles  + '/' + this.formData.id + '/files/guideFile/change';
                this.$http.get(Api.uploadPTWFiles   + '/' + this.formData.id + '/files/picture', {
                    params: {field: 'photo'},
                }).then((res) => {
                    if(res.data.data!=undefined){ this.fileList = res.data.data; }
                })

                this.$http.get(Api.uploadPTWFiles   + '/' + this.formData.id + '/files/guideFile').then((res) => {
                    if(res.data.data!=undefined){
                        res.data.data.forEach(item=>{
                            if(item.field == 'qualification'){
                                this.fileList2.push(item);
                            }else if(item.field == 'workExperience'){
                                this.fileList3.push(item);
                            }else if(item.field == 'change'){
                                this.fileList4.push(item);
                            }
                        })
                    }
                });

                setTimeout(() => {
                    this.$refs.userDom.setCurrentInfo();
                }, 300);
            },
            setOrgName(data){
                this.formData.orgId = data.orgId;
                this.formData.orgName = data.orgName;
                this.rootOrgId = data.orgName;
            },
            setUserInfo(data){
                this.formData.userId = data.userId;
                this.formData.userName = data.userName;
                this.$http.get(Api.getSaStaffEnvinfo + data.userId, {params: {}}).then((res) => {
                    if(res.data.data != null){
                        this.$set(this.formData, 'birthday', res.data.data.birthDate);
                        this.$set(this.formData, 'phoneNumber', res.data.data.cellPhone);
                        this.$set(this.formData, 'education', res.data.data.eduId);
                        this.$set(this.formData, 'gender', res.data.data.genderId == 'M'? '男': '女');
                    }
                })
            },
            saveInfo(){
                this.$refs['formCustom'].validate((valid) => {
                    if(valid){
                        if(this.fileList.length == 0){
                            this.$Notice.error({
                                title: '请上传一寸免冠照！'
                            });
                            return;
                        }
                        if(this.formData.qualification != '无' && this.fileList2.length == 0){
                            this.$Notice.error({
                                title: '请上传任职资格附件！'
                            });
                            return;
                        }
                        this.fileList.map((i)=>{
                            if(i.keyID!=undefined){
                                this.$refs.photoUpload.post(i);
                            }
                        });

                        this.fileList2.map((i)=>{
                            if(i.operation=='add'){
                                this.$refs.qualificationUpload.post(i);
                            }
                        });
                        this.fileList3.map((i)=>{
                            if(i.operation=='add'){
                                this.$refs.workExperienceUpload.post(i);
                            }
                        });
                        this.fileList4.map((i)=>{
                            if(i.operation=='add'){
                                this.$refs.changeUpload.post(i);
                            }
                        });

                        this.buttonLoading = true;
                        if(this.isUpdate){
                            this.$http.put(Api.securityDirectorInfo + '/change',this.formData).then(function(response){
                                this.buttonLoading = false;
                                this.modal1 = false;
                                this.query();
                                this.$Message.success({  content: '保存成功', duration: 4 });
                            });
                        }else{
                            if(!this.IfRepeat){
                                this.$Message.error("该单位已存在安全总监，请勿重复添加");
                                this.buttonLoading = false;
                                return;
                            }
                            this.$http.post(Api.securityDirectorInfo + '/change',this.formData).then(function(response){
                                this.buttonLoading = false;
                                this.modal1 = false;
                                this.query();
                                this.$Message.success({  content: '保存成功', duration: 4 });
                            });
                        }
                    }
                });
            },
            deleteRow(row){
                this.$Modal.confirm({
                    title: '数据删除',
                    content: '<p>确定删除该条信息</p>',
                    okText: '确认',
                    onOk: () => {
                        this.$http.delete(Api.securityDirectorInfo + '/change', {params:{
                                id: row.id,
                                updateUserId: this.userInfo.userId,
                                updateDate: new Date()
                            }}).then((res) => {
                            this.$Message.success({content:'删除成功',duration: 4});
                            this.query();
                        })
                    },
                    cancelText: '取消'
                });
            },
            queryHistory(row){
                this.loading3 = true;
                this.$http.get(Api.getHistory + '/' + row.procinstId, {params: {}}).then((res) => {
                    this.infos3 = res.data;

                    this.loading3 = false;
                }).catch(e => {
                    this.$Message.error("数据获取失败")
                })
            },
            queryLeader(){
                this.spinShow = true;
                this.$http.get(Api.securityDirectorInfo + '/leader' , {params: {companyId: this.formData.orgId, orgName:this.formData.orgName }}).then((res) => {
                    this.leaderList = res.data.data;
                    this.leaderList.push({userId: '8ad810e24f39585c014f395aae380000', userName: '超级管理员'})
                    this.spinShow = false;
                }).catch(e => {
                    this.$Message.error("数据获取失败")
                })
            },
            reportInfo(){
                this.$refs['reportForm'].validate((valid) => {
                    if(valid){
                        let data = {
                            createUserId: this.userInfo.userId,
                            user1: this.reportData.leaderId,
                            key: 'securityDirectorChange',
                            workId: this.reportData.workId,
                            userName: this.userInfo.userName,
                            formKey: 'securityDirectorChangeForm'
                        }
                        this.buttonLoading = true;
                        this.$http.post(Api.submit, data).then(function(response){
                            this.sendMessage(data.user1);
                            this.buttonLoading = false;
                            if(response.data.status == 200){
                                this.$Message.success({ content: '保存成功', duration: 4 });
                                this.query();
                            }else{
                                this.$Message.error({ content: response.data.msg, duration: 4 });
                            }
                            this.modal2 = false;
                        });
                    }
                })
            },
            beforeUpload (file) {
                if(file.type.indexOf("image") == -1){
                    this.$Notice.warning({
                        title: '请上传图片格式附件！',
                    });
                } else{
                    if(this.fileList.length != 0){
                        this.removeFile(this.fileList[0]);
                    }
                    let self = this;
                    let keyID = Math.random().toString().substr(2);
                    file['keyID'] = keyID;
                    let reader = new FileReader();
                    reader.readAsDataURL(file);
                    reader.onload = function(ev) { //文件读取成功完成时触发
                        file['picture'] = ev.target.result; //获得文件读取成功后的DataURL,也就是base64编码
                        self.fileList.push(file);
                    }
                }
                return false;
            },
            viewFile(imgBase64){
                this.visible = true;
                this.fileImgSrc = imgBase64;
            },
            removeFile(file){
                if(file.keyID==undefined){
                    this.$http.delete(Api.uploadMongoFile + "/" + file.id).then((res) => {
                        this.fileList.splice(this.fileList.indexOf(file), 1);
                    }).catch(e => {
                        this.$Message.error("附件删除失败");
                    });
                }else{
                    this.fileList = this.fileList.filter(item => {
                        return item.keyID != file.keyID
                    })
                }
            },
            downloadFile(file){
                let url = Api.uploadPTWFiles + '/file/' + file.id;
                this.$http.get(url, {
                    responseType: 'blob'      //告诉服务器我们需要的响应格式
                }).then((res) => {
                    const aLink = document.createElement("a");
                    let blob = new Blob([res.data], {
                        type: res.bodyBlob.type      //将会被放入到blob中的数组内容的MIME类型
                    });
                    aLink.href = URL.createObjectURL(blob)
                    aLink.download = file.fileName //标题
                    aLink.click()
                    document.body.appendChild(aLink)
                })
            },
            uuid() {
                let s = [];
                let hexDigits = "0123456789abcdef";
                for(let i = 0; i < 32; i++) {
                    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
                }
                s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
                s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
                let uuid = s.join("");
                return uuid
            },
            formatDate(date, fmt) {
                if (typeof date == 'string') {
                    return date;
                }
                if (!fmt) fmt = "yyyy-MM-dd hh:mm:ss";
                if (!date || date == null) return null;
                let o = {
                    'M+': date.getMonth() + 1, // 月份
                    'd+': date.getDate(), // 日
                    'h+': date.getHours(), // 小时
                    'm+': date.getMinutes(), // 分
                    's+': date.getSeconds(), // 秒
                    'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
                    'S': date.getMilliseconds() // 毫秒
                }
                if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
                for (let k in o) {
                    if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
                }
                return fmt
            },
            sendMessage(userId){
                let data = {userId: userId, content: "您有一条企业安全总监推荐表要审批，请登录安全环保信息平台进行审批" };
                this.$http.post(Api.sendMessage ,data);
            },
            export(row){
                this.isSpin = true;
                this.$http.get(Api.securityDirectorInfo + '/download',{
                    params:{
                        id: row.id,
                    },
                    responseType: 'arraybuffer'
                }).then((res) => {
                    const aLink = document.createElement("a");
                    let blob = new Blob([res.data], {
                        type: "application/msword"
                    })
                    aLink.href = URL.createObjectURL(blob);
                    aLink.download = "企业安全总监推荐表.doc" //标题
                    aLink.click();
                    document.body.appendChild(aLink);
                    this.isSpin = false;
                }).catch(e => {
                    this.$Message.error("数据获取失败");
                    this.isSpin = false;
                })
            },
            beforeUpload2(file){
                file.operation = 'add';
                this.fileList2.push(file);
                return false;
            },
            beforeUpload3(file){
                file.operation = 'add';
                this.fileList3.push(file);
                return false;
            },
            beforeUpload4(file){
                file.operation = 'add';
                this.fileList4.push(file);
                return false;
            },
            remove2(file){
                this.fileList2.splice(this.fileList2.indexOf(file), 1);
                if(file.id!=undefined){
                    let url = Api.uploadMongoFile + '/' + file.id;
                    this.$http.delete(url);
                }
            },
            remove3(file){
                this.fileList3.splice(this.fileList3.indexOf(file), 1);
                if(file.id!=undefined){
                    let url = Api.uploadMongoFile + '/' + file.id;
                    this.$http.delete(url);
                }
            },
            remove4(file){
                this.fileList4.splice(this.fileList4.indexOf(file), 1);
                if(file.id!=undefined){
                    let url = Api.uploadMongoFile + '/' + file.id;
                    this.$http.delete(url);
                }
            },
            getSecurityDirectorInfoByName(){
                this.$http.get(Api.securityDirectorInfo + '/change/name', {
                    params: {
                        orgId: this.formData.orgId,
                    }
                }).then(function(res){
                    if(res.data.status== 201){
                        this.$Message.error("该单位已存在安全总监，请勿重复添加");
                        this.formData.userName = '';
                        this.formData.userId = '';
                        this.IfRepeat = false;
                    }else{
                        this.IfRepeat = true;
                    }
                });
            },
            queryInfo(){
                this.loading2 = true;
                let data = {
                    startPage: this.pagedata.currentPage2,
                    pageSize: this.pagedata.pageSize2,
                    status: 3,
                    orgId: this.userInfo.companyId
                };
                data = Object.assign(data,JSON.parse(JSON.stringify(this.formInline2)));
                this.$http.get(Api.securityDirectorInfo, {
                    params: data
                }).then(function(res){
                    this.infos2 = res.data.data.data;
                    this.pagedata.total2 = res.data.data.totalSize;
                    this.loading2 = false;
                }, function(res){
                    this.$Message.error('请求失败');
                });
            },
            cancelInfo(){
                this.formInline2 = {};
                this.queryInfo();
            },
            pageSizeChange2(pageSize){
                this.pagedata.pageSize2 = pageSize;
                this.queryInfo();
            },
            pageChange2(pageNum){
                this.pagedata.currentPage2 = pageNum;
                this.queryInfo();
            },
            changeQualification(data){
                let title = '';
                this.formData.qualificationCheck.map((i=>{
                    title += i + '、';
                }))
                if(title!= '') this.formData.qualification = title.substring(0, title.length -1);
                else this.formData.qualification = ''
            },
            selectUser(){
                this.queryUser();
                this.modal6 = true;
            },
            queryUser(){
                let data = {
                    fromPage: this.pagedata.currentPage,
                    pageSize: this.pagedata.pageSize,
                    companyId : sessionStorage('userId').getObject('userId').companyId
                };
                data = Object.assign(data, JSON.parse(JSON.stringify(this.formInline2)));
                this.loading4 = true;
                this.$http.get(Api.queryUser, {
                    params: data
                }).then(res => {
                    res.data.data.map(i => {
                        if(i.orgInfo != null) {
                            i.orgName = i.orgInfo.orgName;
                            i.orgId = i.orgInfo.orgId;
                            if (i.position != null) {
                                i.positionId = i.position.positionId
                                i.positionName = i.position.positionName
                            }
                        }
                    })
                    this.infos2 = res.data.data;
                    this.pagedata2.total = res.data.total;
                    this.loading4 = false;
                }).catch(e => {
                    this.loading = false;
                    this.$Message.error('请求失败');
                })
            },
            reset(){
                this.formInline2 = {};
                this.queryUser();
            },
            pageSizeChange(pageSize){
                this.pagedata2.pageSize = pageSize;
                this.queryUser();
            },
            pageChange(pageNum){
                this.pagedata2.currentPage = pageNum;
                this.queryUser();
            },
        }
    }
</script>

<style lang='css' scoped>
    @import '../../../index.css';
    .demo-spin-icon-load{
        animation: ani-demo-spin 1s linear infinite;
    }
    .demo-upload-list{
        display: inline-block;
        width: 168px;
        height: 212px;
        text-align: center;
        line-height: 210px;
        border: 1px solid transparent;
        border-radius: 4px;
        overflow: hidden;
        background: #fff;
        position: relative;
        box-shadow: 0 1px 1px rgba(0,0,0,.2);

    }
    .demo-upload-list img{
        width: 100%;
        height: 100%;
    }
    .demo-upload-list-cover{
        display: none;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0,0,0,.6);
    }
    .demo-upload-list:hover .demo-upload-list-cover{
        display: block;
    }
    .demo-upload-list-cover i{
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        margin: 0 2px;
    }
</style>
